const Hashtag = require('../models/hashtag');

const hashtagController = {
    async search(req, res, next) {
        const { limit = 10, offset = 0 } = req.query;

        try {
            const posts = await Hashtag.findByTag(req.params.tag, parseInt(limit), parseInt(offset));
            res.json(posts);
        } catch (error) {
            next(error);
        }
    }
};

module.exports = hashtagController;